<?php
/**
 * Created by PhpStorm.
 * User: titarzhe
 * Date: 18-4-13
 * Time: 上午11:05
 */
namespace app\helpers;
use Phalcon\Di;
use app\models\User;

class UserHelper{
    public static function getUser(){
        $di = Di::getDefault();
        /** @var  $sess \Phalcon\Session\Adapter\Files*/
        $sess = $di->getShared('session');
        $sessUser = $sess->get('user');
        if(!$sessUser){
            return null;
        }
        $user = User::findFirst($sessUser['id']);
        return $user;
    }
}